//
//  LYCTabBarViewController.swift
//  新浪微博
//
//  Created by liuyanchi on 16/7/28.
//  Copyright © 2016年 liuyanchi. All rights reserved.
//

import UIKit

class LYCTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // 设置自定的tabBar
        let lycTabBar = LYCTabBar()
        
        lycTabBar.tintColor = UIColor.orangeColor()
        
        setValue(lycTabBar, forKey: "tabBar")
        
        
   // 调用加载子视图的方法
        addChildViewController()
        
    }
    
    // MARK:-- 再次重载
    func addChildViewController() {
        
        // 首页
        addChildViewController(LYCHomeViewController(), imageName: "tabbar_home", titleString: "首页")
        
        // 消息
        addChildViewController(LYCMessageViewController(), imageName: "tabbar_message_center", titleString: "消息")
        
        // 发现
        addChildViewController(LYCFindViewController(), imageName: "tabbar_discover", titleString: "发现")
        
        // 设置
        addChildViewController(LYCSettingViewController(), imageName: "tabbar_profile", titleString: "我")
        
    }
    
    
    

    // MARK: -- 利用重载,进行设置
    func addChildViewController(childController: UIViewController,imageName: String,titleString: String) {
        
        let nav = UINavigationController(rootViewController: childController)
        
        // 设置tabbar图片
        childController.tabBarItem.image = UIImage(named: imageName)
        
        childController.tabBarItem.selectedImage = UIImage(named: "\(imageName)_highlighted")
    
        // 设置渲染模式
        tabBar.tintColor = UIColor.orangeColor()
        
        childController.title = titleString
        
           addChildViewController(nav)
    }
    
    
    
    
   
}
